package cn.lu.joke.util;

import java.text.SimpleDateFormat;
import java.util.Locale;

public class DateUtils {

    private static String defaultPattern = "yyyy-MM-dd HH:mm:ss";
    private static String mPattern = defaultPattern;
    private static SimpleDateFormat format = new SimpleDateFormat(mPattern, Locale.getDefault());

    public static String getFormatStr(long time) {
        return getFormatStr(defaultPattern, time);
    }

    public static String getFormatStr(String pattern, long time) {
        if (mPattern.equals(pattern)) {
            return format.format(time);
        }
        mPattern = pattern;
        format.applyPattern(pattern);
        return format.format(time);
    }
}
